package cn.zkrt.aims;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.net.URLEncoder;

public class ZLMediaKITTestURL {
    public static void main(String[] args) {
        String baseUrl = "http://192.168.70.149:8080/index/api/addStreamProxy";
        String secret = "H4PrghuTxMyNaW9Ieu3Ut25njN1m89n4";
        String vhost = "test_vhost";
        String app = "test_app";
        String rtspUrlTemplate = "rtsp://admin:admin123456@192.168.60.41:554/cam/realmonitor?channel=%s&subtype=1";
        String filePath = "stream_urls.http";

        try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath))) {
            // 写入文件描述
            writer.write("# This file contains URLs for streaming from 01 to 44.\n");
            writer.write("# Each URL is generated for the corresponding stream number.\n\n");

            for (int i = 1; i <= 44; i++) {
                // 生成前导零
                String streamNumber = String.format("%02d", i);
                String rtspUrl = String.format(rtspUrlTemplate, streamNumber);

                // 生成完整 URL
                String completeUrl = "### " + streamNumber + " ###\n"+String.format("%s?secret=%s&vhost=%s&app=%s&stream=%s&url=%s",
                        baseUrl, secret, vhost, app, streamNumber, URLEncoder.encode(rtspUrl, "UTF-8"));

                // 写入到文件
                writer.write(completeUrl + "\n");
            }

            System.out.println("HTTP file generated successfully: " + filePath);
        } catch (IOException e) {
            System.err.println("Error writing to file: " + e.getMessage());
        }
    }
}
